import java.util.logging.Logger;
import java.util.logging.ConsoleHandler;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.util.logging.Level;
import static java.util.logging.Level.*;

public class Debugger {
    private final Logger logger = Logger.getLogger("gss.generator");
    private final ConsoleHandler cout = new ConsoleHandler();
    private static final Level DEFAULT_LEVEL = FINE;

    public Debugger() {
	cout.setFormatter(
		new Formatter() {
		    public String format(LogRecord record) {
			return record.getMessage() + "\n";
		    }
		}
	    );
	cout.setLevel(ALL);
	logger.addHandler(cout);
	logger.setLevel(ALL);
    }

    public void turnOff() {
	logger.setLevel(WARNING);
    }

    public void turnOn() {
	logger.setLevel(ALL);
    }

    public void print(String msg) {
	logger.log(DEFAULT_LEVEL, msg);
    }
}
